<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        let students = [
            { name: '刘德华', age: 21, gender: '男', hometown: '香港' },
            { name: '张学友', age: 22, gender: '男', hometown: '香港' },
            { name: '梅艳芳', age: 23, gender: '女', hometown: '香港' },
            { name: '郭富城', age: 24, gender: '男', hometown: '香港' }
        ];

        for (let i = 0; i < students.length; i++) {
            // console.log(students[i]);//students[i]就是对象
            for (let key in students[i]) {
                // console.log(key); // 输出对象的属性名,但是是字符串类型,如'name' 'age' 'gender' 'hometown'
                console.log(students[i][key]); // 输出对应的值,这里相当于students[i]['name'] students[i]['age'] students[i]['gender'] students[i]['hometown']
            }
        }
    </script>
</body>

</html>